<template>
  <div class="container">
    <div class="content-head" style="margin-bottom: 20px;">
      <div class="sort-keys">
        <span style="margin-left: 20px; margin-right: 6px;">日期:</span>
        <IDatePicker :showTime="false" style="margin-left: 10px;" placeholder="不选则不限制" v-model="filter.min_day"></IDatePicker>
        至
        <IDatePicker :showTime="false" style="margin-left: 0px;" placeholder="不选则不限制" v-model="filter.max_day"></IDatePicker>

      </div>
    </div>
    <a-table class="table" :rowKey="row => row.id" :dataSource="list">
      <a-table-column title="日期" width="60px">
        <template slot-scope="row">
          <div>{{row.date}}</div>
        </template>
      </a-table-column>
      <a-table-column title="发起的提现" width="60px">
        <template slot-scope="row">
          <div>{{$tool.formatPrice(row.fqtx)}}</div>
        </template>
      </a-table-column>
      <a-table-column title="实际支付" width="60px">
        <template slot-scope="row">
          <div v-if="row.fqtx * 1 > row.xzsr * 1" style="color:red">{{$tool.formatPrice(row.xzsr)}}</div>
          <div v-else>{{$tool.formatPrice(row.xzsr)}}</div>
        </template>
      </a-table-column>
      <a-table-column title="提货红包价值" width="60px">
        <template slot-scope="row">
          <div>{{$tool.formatPrice(row.cshbzz)}}</div>
        </template>
      </a-table-column>
      <a-table-column title="提货积分价值" width="60px">
        <template slot-scope="row">
          <div>{{row.csjfzz}}</div>
        </template>
      </a-table-column>
      
    </a-table>


  </div>
</template>

<script>
  import { getMxsearchList } from '@/api/visitors'
  import moment from 'moment'
  import IDatePicker from "@/components/IDatePicker/IDatePicker.vue"

  export default {
    components: {
      IDatePicker
    },
    data() {
      return {
        info: {},
        list: [],
        filter: {
          min_day: '',
          max_day: ''
        }
      }
    },
    computed: {
    },
    props: {
      user_id: 0,
    },
    created() {
      this.fetchData();
    },
    filters: {
      formatDate (value) {
        return value ? moment(value).fromNow() : ''
      },
      formatDate2 (value) {
        return value ? moment(value).format('YYYY-MM-DD') : ''
      }
    },
    mounted() {},
    watch: {
      'filter.min_day'() {
        if(this.filter.min_day && this.filter.max_day){
          this.fetchData()
        }
      },
      'filter.max_day'() {
        if(this.filter.min_day && this.filter.max_day){
          this.fetchData()
        }
      }
    },
    methods: {
       fetchData () {
        getMxsearchList({
          user_id:this.user_id,
          min_day: this.filter.min_day,
          max_day: this.filter.max_day,
        }).then(res => {
          this.list = res.data.list
        })
      },
      cancel() {
        this.$router.back(-1)
      }
    }
  }
</script>

<style lang="scss" scoped>
  .headimg {
    width: 28px;
    height: 28px;
    border-radius: 50%;
  }


  .form-container {
    padding-bottom: 120px;
  }

  .container {
    .btn {
      margin-right: 30px;
    }
  }

  .tips-c {
    margin-bottom: 20px;
    font-weight: 500;
  }
</style>
